package com.sm.healthy.model

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.sm.healthy.utils.CacheUtil
import com.sm.healthy.base.App
import com.sm.healthy.data.bean.OxygenEntity
import com.sm.healthy.ext.gson
import kotlinx.coroutines.launch
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.util.LogUtils

class BloodGlucoseViewModel : BaseViewModel() {
    val TAG = "UserCenterAddViewModel"

    var bloodValue = "0.0"
    var startBtn = "开始测量"

    val uid = CacheUtil.getCurUid()
    val dao = App.database.oxygenDao()

    val bloodPressureEntity = MutableLiveData(OxygenEntity(uid))

    fun insert() {
        bloodPressureEntity.value?.let {
            LogUtils.debugInfo(TAG, "data = ${gson.toJson(it)}")
            viewModelScope.launch {
                dao.insert(it)
            }
        }
    }
}